<?php
/**
 * Created by PhpStorm
 * USER MingTingLiang   QQ 915802070
 * Date 2020-12-16-016   16:35
 */


abstract class UserReg
{
    public $step = "step1";
    public $next = false;
    public $last = false;

    public function setNextStep($object)
    {
        $this->next = $object;
        $object->last = $this;
    }

    public function stepNext($user)
    {
        if ($user->step == $this->step) {
            if ($this->next) {
                $user->step = $this->next->step; //交控制权
                return $user;
            }
        } else {
            if ($this->next) {
                return $this->next->stepNext($user);
            }
        }
    }
}